/*
 * Copyright (c) 2018.
 * 北京九思金信科技有限公司对该文件内容保留所有权利。
 * 未经许可，不得私自拷贝、传播、发布、引用该文件内容，违者将被追究法律责任。
 */

// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from "vue";
import FastClick from "fastclick";
import router from "./router";
import App from "./App";

// import Home from './components/HelloFromVux'

import BScroll from "better-scroll"; // 滚动插件

import "./assets/css/reset.css"; // 样式初始化文件
import "./assets/css/border.css"; // 边框初始化文件
import "./assets/css/fontStyle.less"; // 引入字体样式
import "./assets/css/theme.less"; // 引入字体样式
import store from "./store/store"; //vuex数据组件
import axios from "axios";
Vue.prototype.$axios = axios;

import "./assets/css/animate.css"; // 引入动画库
import "./assets/iconfont/iconfont.css"; // 引入动画库
// Vue.use(animated)

Vue.config.productionTip = false;
FastClick.attach(document.body); // 全局处理点击延迟300毫秒bug

// 格式化时间的过滤器
Vue.filter("dateFormat", originVal => {
  var myDate = new Date().getTime();
  var gapDate = myDate - originVal;
  const dd = new Date(myDate);
  const dt = new Date(originVal);
  const y = dt.getFullYear();
  const m = (dt.getMonth() + 1).toString().padStart(2, "0");
  const d = dt
    .getDate()
    .toString()
    .padStart(2, "0");
  const ds = dd
    .getDate()
    .toString()
    .padStart(2, "0");

  const hh = dt
    .getHours()
    .toString()
    .padStart(2, "0");
  const mm = dt
    .getMinutes()
    .toString()
    .padStart(2, "0");
  const ss = dt
    .getSeconds()
    .toString()
    .padStart(2, "0");

  if (gapDate < 86400000) {
    if (ds != d) {
      return `昨天 ${hh}:${mm}:${ss}`;
    } else {
      return `今天 ${hh}:${mm}:${ss}`;
    }
  } else {
    return `${y}/${m}/${d}`;
  }
});

// 图片懒加载
import VueLazyload from "vue-lazyload";
Vue.use(VueLazyload, {
  loading: require('@/assets/img/loadingImg.png')
});

new Vue({
  el: "#app-box",
  router,
  store,
  components: { App },
  template: "<App/>"
});
